package demoinner;

class OuterClass {
    public int data1 = 1;
    private int data2 = 2;
    public static int data3 = 3;

    //静态内部类
    static class InnerClass {
        public int data1 = 1;
        private int data4 = 4;
        private int data5 = 5;
        public static int data6 = 6;


        public void testInner() {
            System.out.println("InnerClass: : testInner().........");
            OuterClass outerClass = new OuterClass();
            System.out.println(outerClass.data1);
            //System.out.println(OuterClass.this.data1);
            System.out.println(outerClass.data2);
            System.out.println(data3);
            System.out.println(data4);
            System.out.println(data5);
            System.out.println(data6);
        }
    }

    public void test() {
        System.out.println("OuterClass ::test()......");
    }
}

class OuterClass2 {
    public int data1 = 1;
    private int data2 = 2;

    public static int data3 = 3;

    class InnerClass {
        public int data1 = 9999999;
        public int data4 = 4;
        private int data5 = 5;
        public static int data6 = 6;

        public void test() {
            //1. 给一个外部类对象
            System.out.println(data1);
            //2. 外部类名.this
            System.out.println(OuterClass2.this.data1);
            System.out.println(data2);
            System.out.println(data3);
            System.out.println(data4);
            System.out.println(data5);
            System.out.println(data6);
        }
    }


}

class OutClass3 {

    public void test() {
        int p = 10;
        class A {
            public int data1 = 1;

            public void xx() {
                System.out.println(p);
            }
        }

        A a = new A();
        a.xx();
    }

    public void test2() {

    }

}
interface Greeting {
    void greet();
    public default void test() {

    }
    public static void test2() {

    }
    private static void test3() {

    }
}
public class Test {

    public static int data = 10;
    //data = 20;

    public int data1 = 10;
    //data1 = 20;

    public static void main(String[] args) {
        Greeting g = new Greeting() {

            public int data1;
            public static int a = 10;

            @Override
            public void greet() {
                System.out.println("haha");
            }
        };
        g.greet();
    }

    public static void main2(String[] args) {
        OuterClass2 outerClass2 = new OuterClass2();
        OuterClass2.InnerClass innerClass = outerClass2.new InnerClass();
        OuterClass2.InnerClass innerClass2 = new OuterClass2().new InnerClass();
        innerClass2.test();
    }

    public static void main1(String[] args) {
        OuterClass.InnerClass innerClass = new OuterClass.InnerClass();
        innerClass.testInner();
    }
}
